#include<stdio.h>
typedef struct TreeNode
{
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

TreeNode* maketree(char* arr, int* count)
{
    if (arr[*count] == '#' || arr[*count] == '\0')
    {
        return NULL;
    }
    TreeNode* newnode = (TreeNode*)malloc(sizeof(TreeNode));
    newnode->val = arr[(*count)++];

    newnode->left = maketree(arr, count);
    (*count)++;
    newnode->right = maketree(arr, count);
    return newnode;
}

void Inorder(TreeNode* root)
{
    if (root == NULL)
    {
        return;
    }
    Inorder(root->left);
    printf("%c ", root->val);
    Inorder(root->right);
}

int main()
{
    char arr[101];
    scanf("%s", arr);
    int count = 0;
    TreeNode* tree = maketree(arr, &count);
    Inorder(tree);
    return 0;
}